package com.woniuxy.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniuxy.dto.WarehouseDto;
import com.woniuxy.dto.WarehouseShopDto;
import com.woniuxy.entity.WarehouseShop;
import com.woniuxy.mapper.WarehouseShopMapper;
import com.woniuxy.service.WarehouseShopService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.util.WoniuBeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 仓库关联表 服务实现类
 * </p>
 *
 * @author zcx,ftl,gr,rhs
 * @since 2021-12-31
 */
@Service
public class WarehouseShopServiceImpl extends ServiceImpl<WarehouseShopMapper, WarehouseShop> implements WarehouseShopService {

    @Override
    public List<WarehouseShopDto> listWareHouseByShopId(Integer shopId) {
        List<WarehouseShop> warehouseShops = list(new QueryWrapper<WarehouseShop>().eq("shop_id", shopId));
        List<WarehouseShopDto> warehouseShopDtos = WoniuBeanUtils.copyList(warehouseShops, WarehouseShopDto.class);
        return warehouseShopDtos;
    }

    @Override
    public List<WarehouseShopDto> listShopByHouseId(Integer warehouseId) {
        List<WarehouseShop> warehouseShops = list(new QueryWrapper<WarehouseShop>().eq("warehouse_id", warehouseId));
        List<WarehouseShopDto> warehouseShopDtos = WoniuBeanUtils.copyList(warehouseShops, WarehouseShopDto.class);
        return warehouseShopDtos;
    }
}
